import Vue from 'vue'
import store from './store'
import App from './App'
import Cache from './utils/cache'
// import util from 'utils/util'
import configs from './config/app.js'
import util from 'utils/util'
import * as uu from './utils/date.js'
import PageTuring from './utils/page.js'
import {WXMENU} from '@/config/app.js'
import track from "./mixins/track";
import {
	wxAuthorize
} from '@/utils/wechat'

import {
	checkTokenEndTime
} from '@/utils/auth.js'
// #ifdef H5
Vue.prototype.$wxAuthorize = wxAuthorize;
// #endif
Vue.prototype.$util = util;
Vue.prototype.$noMultipleClicks = util.noMultipleClicks
Vue.prototype.$p = util.unitConvert
Vue.prototype.$uu = uu
Vue.prototype.$Cache = Cache;
// Vue.prototype.$util = util;
Vue.prototype.$config = configs;
Vue.prototype.$pageTuring = PageTuring
Vue.prototype.$WXMENU = WXMENU;
// #ifdef H5 
import vConsole from './common/js/vconsole'

let arr = ['dev', 'test', 'uat']
arr.forEach(v => {
	if (process.env.ENV_TYPE.includes(v)) {
		new vConsole()
	}
})
// #endif


//导入友盟埋点



// #ifdef MP-WEIXIN
import uma from './utils/uma.js'
Vue.use(uma);
// #endif

// 注册全局埋点事件
import umaTrack from 'utils/umaTrack'
Vue.prototype.$umaTrack = umaTrack;

const msg = (title, duration = 1500, mask = false, icon = 'none') => {
	//统一提示方便全局修改
	if (Boolean(title) === false) {
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

const prePage = () => {
	let pages = getCurrentPages();
	let prePage = pages[pages.length - 2];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}


Vue.mixin(track)
Vue.mixin({
	onShow(op) {
	  let opt = {
		title: "助融报告",
		desc: "一键支持用户免费自查税信息，用户授权后免费自查，生成报告，简单方便。",
		link: util.getPageUrl({}, ""),
	  };
	  // #ifdef H5
	  util.setWXConfig(opt);
	  // #endif
	  
	},
	onLoad(op) {},
  });

Vue.config.productionTip = false
Vue.prototype.$fire = new Vue();
Vue.prototype.$store = store;
Vue.prototype.$api = {
	msg,
	prePage
};

App.mpType = 'app'

console.log(process.env.VUE_APP_BASE_URL, '获取处于当前开发环境的url');
console.log(process.env.ENV_TYPE, '获取当前处于哪个开发环境');

const app = new Vue({
	...App
})
app.$mount()